package chapter5;

/**
 * 通过this关键字在方法中返回自身
 */
public class ReturnThis {
    public int age;
    public ReturnThis grow() {
        age++;
        return this;
    }

    public static void main(String[] args) {
        ReturnThis rt = new ReturnThis();
        rt.grow().grow().grow();
        System.out.println(rt.age);
    }
}
